﻿/***************************************************************************
 *  Project: WebControlSample
 *  File:    DataGridViewProgressBarColumn.cs
 *  Version: 1.0.0.0
 *
 *  Copyright ©2012 Perikles C. Stephanidis; All rights reserved.
 *  This code is provided "AS IS" without warranty of any kind.
 *__________________________________________________________________________
 *
 *  Notes:
 *
 *  Creates a DataGridView Column with cells that render a progress-bar.
 *   
 ***************************************************************************/

#region Using
using System;
using System.Windows.Forms;
using System.ComponentModel;
#endregion

namespace WebControlSample.ComponentModel
{

    #region DataGridViewProgressBarColumn
    public class DataGridViewStatusColumn : DataGridViewImageColumn
    {
        public DataGridViewStatusColumn()
        {
            this.CellTemplate = new DataGridViewStatusCell();
        }
    }
    #endregion

    #region DataGridViewStatusCell
    public class DataGridViewStatusCell : DataGridViewImageCell
    {

        public DataGridViewStatusCell()
        {
            this.ValueType = typeof( bool );
        }

        protected override object GetFormattedValue( object value,
            int rowIndex,
            ref DataGridViewCellStyle cellStyle,
            TypeConverter valueTypeConverter,
            TypeConverter formattedValueTypeConverter,
            DataGridViewDataErrorContexts context )
        {
            bool statusVal = (bool)value;
            return statusVal ? Properties.Resources.development_51 : Properties.Resources.development_52;
        }
    }
    #endregion

}